<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!-- 引入cluetip  -->
<script language="javascript" type="text/javascript" src="js/cluetip/jquery.cluetip.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="style/jquery.cluetip.css" />

 
<!-- 引入visual search -->
<script src="js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>
<script src="js/underscore-1.4.3.js" type="text/javascript"></script>
<script src="js/backbone-0.9.10.js" type="text/javascript"></script>
<script src="js/visualsearch.js" type="text/javascript"></script>
<!--[if (!IE)|(gte IE 8)]><!-->
  <link href="style/visualsearch-datauri.css" media="screen" rel="stylesheet" type="text/css" />
<!--<![endif]-->


<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
  var visualSearch = VS.init({
    container  : $('#search_box_container'),
    query      : 'country: "United States" "U.S. State": "New York" account: 5-samuel',
    showFacets : true,
    unquotable : [
      'text',
      'account',
      'filter',
      'access'
    ],
    callbacks  : {
      search : function(query, searchCollection) {
        var $query = $('#search_query');
        var count  = searchCollection.size();
        $query.stop().animate({opacity : 1}, {duration: 300, queue: false});
        $query.html('<span class="raquo">&raquo;</span> You searched for: ' +
                    '<b>' + (query || '<i>nothing</i>') + '</b>. ' +
                    '(' + count + ' facet' + (count==1 ? '' : 's') + ')');
        clearTimeout(window.queryHideDelay);
        window.queryHideDelay = setTimeout(function() {
          $query.animate({
            opacity : 0
          }, {
            duration: 1000,
            queue: false
          });
        }, 2000);
      },
      facetMatches : function(callback) {
        callback([
          'account', 'filter', 'access', 'title',
          { label: 'city',       category: 'location' },
          { label: 'country',    category: 'location' },
          { label: 'U.S. State', category: 'location' },
        ]);
      },
      valueMatches : function(facet, searchTerm, callback) {
        switch (facet) {
        case 'account':
            callback([
              { value: '1-amanda', label: 'Amanda' },
              { value: '2-aron',   label: 'Aron' },
              { value: '3-eric',   label: 'Eric' },
              { value: '4-jeremy', label: 'Jeremy' },
              { value: '5-samuel', label: 'Samuel' },
              { value: '6-scott',  label: 'Scott' }
            ]);
            break;
          case 'filter':
            callback(['published', 'unpublished', 'draft']);
            break;
          case 'access':
            callback(['public', 'private', 'protected']);
            break;
          case 'title':
            callback([
              'Pentagon Papers',
              'CoffeeScript Manual',
              'Laboratory for Object Oriented Thinking',
              'A Repository Grows in Brooklyn'
            ]);
            break;
          case 'city':
            callback([
              'Cleveland',
              'New York City',
              'Brooklyn',
              'Manhattan',
              'Queens',
              'The Bronx',
              'Staten Island',
              'San Francisco',
              'Los Angeles',
              'Seattle',
              'London',
              'Portland',
              'Chicago',
              'Boston'
            ]);
            break;
          case 'U.S. State':
            callback([
              "Alabama", "Alaska", "Arizona", "Arkansas", "California",
              "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida",
              "Georgia", "Guam", "Hawaii", "Idaho", "Illinois",
              "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana",
              "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota",
              "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
              "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
              "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania",
              "Puerto Rico", "Rhode Island", "South Carolina", "South Dakota", "Tennessee",
              "Texas", "Utah", "Vermont", "Virginia", "Virgin Islands",
              "Washington", "West Virginia", "Wisconsin", "Wyoming"
            ]);
            break;
          case 'country':
            callback([
              "China", "India", "United States", "Indonesia", "Brazil",
              "Pakistan", "Bangladesh", "Nigeria", "Russia", "Japan",
              "Mexico", "Philippines", "Vietnam", "Ethiopia", "Egypt",
              "Germany", "Turkey", "Iran", "Thailand", "D. R. of Congo",
              "France", "United Kingdom", "Italy", "Myanmar", "South Africa",
              "South Korea", "Colombia", "Ukraine", "Spain", "Tanzania",
              "Sudan", "Kenya", "Argentina", "Poland", "Algeria",
              "Canada", "Uganda", "Morocco", "Iraq", "Nepal",
              "Peru", "Afghanistan", "Venezuela", "Malaysia", "Uzbekistan",
              "Saudi Arabia", "Ghana", "Yemen", "North Korea", "Mozambique",
              "Taiwan", "Syria", "Ivory Coast", "Australia", "Romania",
              "Sri Lanka", "Madagascar", "Cameroon", "Angola", "Chile",
              "Netherlands", "Burkina Faso", "Niger", "Kazakhstan", "Malawi",
              "Cambodia", "Guatemala", "Ecuador", "Mali", "Zambia",
              "Senegal", "Zimbabwe", "Chad", "Cuba", "Greece",
              "Portugal", "Belgium", "Czech Republic", "Tunisia", "Guinea",
              "Rwanda", "Dominican Republic", "Haiti", "Bolivia", "Hungary",
              "Belarus", "Somalia", "Sweden", "Benin", "Azerbaijan",
              "Burundi", "Austria", "Honduras", "Switzerland", "Bulgaria",
              "Serbia", "Israel", "Tajikistan", "Hong Kong", "Papua New Guinea",
              "Togo", "Libya", "Jordan", "Paraguay", "Laos",
              "El Salvador", "Sierra Leone", "Nicaragua", "Kyrgyzstan", "Denmark",
              "Slovakia", "Finland", "Eritrea", "Turkmenistan"
            ], {preserveOrder: true});
            break;
        }
      }
    }
  });
});

/*
 * sstonehu

$(".VS-search").css("width",($("#search").width()-80));
var bs_btn = $("<input class='search' name='bar_search' type='button' id='bar_search' value='搜索' />");
$("#search_query").after(bs_btn);

* 暂不添加搜索按键
*/

</script>

<!-- 引入jqgrid -->
<link rel="stylesheet" type="text/css" media="screen" href="style/jquery-ui-1.10.3.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="style/ui.jqgrid.css" />

<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.src.js" type="text/javascript"></script>

<script type="text/javascript">
jQuery("#list5").jqGrid({ 
		url:'houseListAjax', 
		datatype: "json", 
		colNames:['houseDelid','房源编号','聚焦','独家','级别','楼盘','户型','面积(㎡)','朝向','楼层','钥匙','实堪','单价(万)','报价(万)','跟进','房屋状态','新建日期','所属人','带看','共享池','价格变动'],
		colModel:[
			   		{name:'houseDelId',index:'House_Del_Id',align:"center",width:20,key:true,sortable:true,resizable:false,hidden:true},
			   		{name:'houseCode',index:'d.house_Code',align:"center", width:43,sortable:true,title:false},
			   		{name:'focus',index:'${focusOrder }',align:"center",width:12,resizable:false,title:false,formatter: getFocus},
		            {name:'exclusive',index:'d.is_the_sole_agency',align:'center',width:20,formatter:getExclusive},
		            {name:'rank',index:'rank',align:"center",width:10, resizable:false,title:false},
		            {name:'resblockName',index:'h.RESBLOCK_NAME',align:"center",width:30, resizable:false,title:false},
		            {name:'houseFrame',index:'h.BEDROOM_AMOUNT',align:"center",width:20,resizable:false,hidden:false},
		            
		            {name:'buildSize',index:'h.BUILD_SIZE', align:"center",width:20,resizable:false,title:false},
		            {name:'orientation',index:'h.Orientation',align:"center",width:10,resizable:false,title:false},
		            {name:'floor',index:'floor',align:"center",width:15, resizable:false,title:false},
		            
		            {name:'hdelKey',index:'h.IS_KEY',align:"center",width:10, resizable:false,title:false,formatter : getKey},
		            {name:'pic',index:'d.HAS_PICTURE',align:"center",width:10,resizable:false,title:false,formatter : getPic},
		            
		            {name:'unitPrice',index:'unit_price',align:"center",width:20, resizable:false,title:false},
		            {name:'totalPrice',index:'Total_Prices',align:"center",width:20, resizable:false,title:false,formatter:getTotalPrice,},
		            {name:'track',index:'track_num', align:"center",width:10,resizable:false,title:false,formatter : getTrack},
		            {name:'houseState',index:'House_Status',resizable:false,align:"center",width:20,title:false},
		            
		            {name:'createdTime',index:'d.created_Time',align:"center",width:30,},
		            {name:'hdelHolderName',index:'Holder_Name',align:"center",width:15,resizable:false,title:false},
		            {name:'showCount',index:'Showing_Times', align:"center",width:10,resizable:false,title:false},
		            {name:'isInPool',index:'isInPool',align:"center",width:20,sortable:false,hidden:true,resizable:false,title:false},
		            {name:'price_change_type',index:'price_change_type',align:"center",width:20,resizable:false,title:false,hidden:true }
			   	],
		rowNum:10, rowList:[10,20,30], 
		pager: '#pager5', 
		sortname: 'id', 
		viewrecords: true, 
		sortorder: "desc", 
		//caption:"Simple data manipulation", 
		editurl:"someurl.php",
		loadComplete: function (){
			$('.jt').cluetip({tracking: true});
			/*$('.jt').cluetip({
				  cluetipClass: 'jtip', arrows: false,
				  activation: 'click', 
				  dropShadow: true, 
				  height: '150px',
				  width: '400px', 
				  sticky: true,
				  positionBy: 'fixed',
				  leftOffset: '-250px',
				  topOffset: '25px',
				  closePosition: 'title',
				  closeText: '<img src="style/images/cluetip/cross.png" alt="" />'
				});	*/	
			}
		}).navGrid("#pager5",{edit:false,add:false,del:false}); 
		
		
jQuery("#a1").click(
		function(){ 
			var id = jQuery("#list5").jqGrid('getGridParam','selrow'); 
			if (id) { var ret = jQuery("#list5").jqGrid('getRowData',id); 
					alert("id="+ret.id+" invdate="+ret.invdate+"..."); 
					}
			else { alert("Please select row");} 
			});
jQuery("#a2").click( 
		function(){ 
			var su=jQuery("#list5").jqGrid('delRowData',12); 
			if(su) alert("Succes. Write custom code to delete row from server"); 
			else alert("Allready deleted or not in list"); 
			}); 
jQuery("#a3").click( 
		function(){ 
			var su=jQuery("#list5").jqGrid('setRowData',11,{amount:"333.00",tax:"33.00",total:"366.00",note:"<img src='images/user1.gif'/>"}); 
			if(su) alert("Succes. Write custom code to update row in server"); 
			else alert("Can not update"); 
			}); 
jQuery("#a4").click( 
		function(){ 
			var datarow = {id:"99",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}; 
			var su=jQuery("#list5").jqGrid('addRowData',99,datarow); 
			if(su) alert("Succes. Write custom code to add data in server"); 
			else alert("Can not update"); 
			});
			
$("#list5").setGridWidth($(".pageCentent").width());
$("div#navTab .navTab-panel").css("overflow","auto");


function getFocus(cellvalue, options, rowObject){
			var type = parseInt(cellvalue);    
			switch(type){
			case 1:
				return '<img class="jt" style="width:26px; height:16px; " src="style/images/focus/focus_d.png" border="0" alt=""/>';
			case 2:
				return '<img class="jt" style="width:26px; height:16px; " src="style/images/focus/focus_bd.png" border="0" alt=""/>';
			case 3:
				return '<img class="jt" style="width:26px; height:16px; " src="style/images/focus/focus_b.png" border="0" alt=""/>';
			default:
				return '';
			}
	}
	
function getPic(cellvalue, options, rowObject){
	if(cellvalue == 1){
		return '<img src="style/images/houseDel/icon_pic.gif" border="0" alt=""  />';    //readPic('+rowObject.houseDelId+')
	}else{
		return '';
	}
}

function getTrack(cellvalue, options, rowObject){
	var trackTemp = '';
    if(cellvalue > 0){
    	trackTemp = '<img style="width:22px; height:22px; " src="style/images/houseDel/track.png" border="0" alt=""/>';
	 	}else{
		    trackTemp = '<img style="width:22px; height:22px; " src="style/images/houseDel/track1.png" border="0" alt=""/>';
	 	}
    return trackTemp;
}	

function getKey(cellvalue, options, rowObject){
	var keyTemp = '';
	if(cellvalue == 1){
		keyTemp = '<img style="width:16px; height:16px; " class="jt" rel="${ctx}/keymanage/keyInfoAjax.action?houseDelId='+rowObject.houseDelId+'" src="style/images/houseDel/icon_ys.gif" border="0" alt=""/>';
     }
	return keyTemp;
}

function getTotalPrice(cellvalue, options, rowObject){
	var keyTemp = '';
	var pct = rowObject.price_change_type;
	var strImg = '';
	if (pct=='1'){ //上升
	   strImg ='<img style="width:16px; height:16px; " class="jt" rel="${ctx}/houinfmg/priceInfoAjax.action?houseDelId='+rowObject.houseDelId+'" src="style/images/houseDel/up.gif" border="0" alt=""/>';
	}
	if (pct=='2'){//下降
	   strImg ='<img style="width:16px; height:16px; " class="jt" rel="${ctx}/houinfmg/priceInfoAjax.action?houseDelId='+rowObject.houseDelId+'" src="style/images/houseDel/down.gif" border="0" alt=""/>';
	}
	keyTemp = cellvalue+strImg;
	return keyTemp;
}

function getExclusive(cellvalue, options, rowObject){
	var agencyandfeeType = '';
	
	if(cellvalue=="0"){
		agencyandfeeType = '否';
	}else if(cellvalue=="1"){
		agencyandfeeType = '限时';
	}else if(cellvalue=="2"){
		agencyandfeeType = '独家';
	}else{
		agencyandfeeType = '';
	}
		
    return agencyandfeeType;
}

/**
 * 打开或隐藏高级搜索
 */

function swithSearch(){
	var dp = $("#highSerchContent").css("display");
	if(dp == "none"){
		$("#highSerchContent").css("display","block");
		$("#hs_btn").val("收起");
	}
	else {
		$("#highSerchContent").css("display","none");
		$("#hs_btn").val("高级搜索");
	}	
};

$("#hs_btn").click(swithSearch);

</script> 
<div class="accountInfo">
	
	<div id="search_box_container"></div>
<!-- 
	隐藏search_query
    <div id="search_query">&nbsp;</div>
 -->
     <jsp:include page="highSearch.jsp"/>
	<div id="search"> 
			<input class='hs_btn' name='hs_btn' type='button' id='hs_btn' value='高级搜索' />
			<input class='search' name='bar_search' type='button' id='bar_search' value='搜索' />
	</div>
</div>
<div class="pageCentent">
	<table id="list5"></table>
	<div id="pager5"></div>
</div>